﻿using MediatR;
using UserLicense.Applicationes.Command;
using UserModels;
using UserRepositorys.Intface;

namespace UserLicense.Applicationes.CommandHandler
{
    public class DeptListCommandHandler : IRequestHandler<DeptListCommand, List<DeptInfoModel>>
    {
        private readonly IDeptRepository deptRepository;
        public DeptListCommandHandler(IDeptRepository deptRepository)
        {
            this.deptRepository = deptRepository;
        }

        /// <summary>
        /// 查询所有部门信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<List<DeptInfoModel>> Handle(DeptListCommand request, CancellationToken cancellationToken)
        {
            return await deptRepository.GetDeptList();
        }
    }
}
